﻿using System;
using System.Collections.Generic;
using System.Text;
using Entity;

namespace DAO
{
    public class UserDAO
    {
        public static User Login(string Username)
        {
            connectDB.open_DB();
              cmd = new SqlCommand();
            cmd.CommandText = "Login";
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("user_name", SqlDbType.NVarChar).Value = Username;
            cmd.Connection = connectDB.conn;
            SqlDataReader myReader = cmd.ExecuteReader();


            NguoiDung result;

            if (myReader.Read())
            {
                result = new NguoiDung();
                result.Username = myReader[0].ToString();
                result.Password = myReader[1].ToString();



            }
            else
            {
                return null;
            }

            myReader.Close();

            return result;
            //conn.Close();
            //Console.ReadLine();
        }
    }
}
